import scala.collection.immutable.HashSet
import scala.collection.mutable.ListBuffer

package codegen{	
	class RootSyntaxNode extends SyntaxNode 
	{
	  protected[codegen] val smartChildren  = ListBuffer[SmartSyntaxNode](); 
	  
	  def addChild(child : SmartSyntaxNode) = 
	  {
	    var iter = this.smartChildren.iterator;
	    var inserted = false
	    while(iter.hasNext && (!inserted))
	    {
	      var current = iter.next(); 
	      if(current.isDependent(child.name))
	      {
	       var i = children.indexOf(current);
	       smartChildren.insert(i,child)
	       inserted = true
	      }      
	        
	    }
	    if (! inserted) smartChildren.append(child) 
      } 
	}
}